home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq15.zip / MBBSREG.SLT < prev    next >
Text File  |  1991-01-24  |  10KB  |  288 lines

  1. //-----------------------------------------------------------
  2. // MBBSREG.SL? Automatic registration to a new MBBS.
  3. //
  4. // Please look at the comments through the whole file, and modify to
  5. // suit your needs before you use it. Then recompile with CS MBBSREG. 
  6. //-----------------------------------------------------------
  7.  
  8. str thisBBStype[]="MBBS"     // Works only for MBBS.
  9.    ,line       [80]          // Line for string storage.
  10.    ,temp        [4]          // Temporary for short strings.
  11.                              // For the Global storage:
  12.    ,global   []="GLOBAL"     // Global script.
  13.    ,bbstype  []="BTYPE"      // BBS type.
  14.    ,hprot    []="HPROT"      // Current protocol.
  15.    ,addr     []="ADDR"       // Address
  16.    ,mail     []="MAIL"       // Mail address
  17.    ,htel     []="HTEL"       // Home phone
  18.    ,wtel     []="WTEL"       // Work phone
  19.    ,passw    []="PASSW"      // Actual password
  20.    ;     
  21.  
  22. int tol = 300                // No activity for ½ minute
  23.    ,i, x                     // makes script time out.
  24.    ,stat, tmark
  25.    ;
  26.  
  27. //-----------------------------------------------------------
  28. // Script starts here.
  29. //-----------------------------------------------------------
  30.  
  31. main()
  32. {
  33.   entry();                               // Updates colors & status bar. 
  34.  
  35. // Only if online.
  36.  
  37.   if (!carrier()) 
  38.   { alarm(1);
  39.     status_wind ("THIS SCRIPT ONLY WORKS IF YOU'RE ONLINE!",20);
  40.     return (0);
  41.   }
  42.  
  43.   call (global,"R",bbstype,line);        // Get BBS type. Should be MBBS.
  44.  
  45.   if (line != thisBBStype)
  46.   { wrongBBS();
  47.     return (-1);
  48.   }
  49.  
  50. // Start tracking incoming text.
  51.  
  52.   if (SECTION1()                         // These routines 
  53.   || SECTION2())                         // return 0 if all's OK.
  54.   { status_wind ("Logon/registration failed!!",20);
  55.     return (-1);
  56.   }
  57.  
  58.   cputs ("X S^M");                       // Set SuperExpert mode.
  59.   waitfor (" Command",2);                // Wait for next command.
  60.  
  61.   cputs ("U M^M");                       // Go to Utility menu.
  62.   waitfor ("ANSI terminal:");
  63.   cputs ("Y Y Y Y Y Y^M");               // Set mode; all to YES.
  64.         
  65.   waitfor (" Command",2);                // Wait for next command.
  66.   cputs ("FILT^M");                      // Switch filter off.
  67.  
  68.   waitfor (" Command",2);                // Wait for next command.
  69.   cputs ("T ");                          // Set transfer protocol.       
  70.   output (hprot);
  71.   waitfor (" Command",2);                // Wait for next command.
  72.  
  73.   cputs ("AF Z^M");                      // Auto Format is Zip
  74.   waitfor (" Command",2);                // Wait for next command.
  75.  
  76.   cputs ("L 0^M");                       // Set no paging,
  77.   waitfor (" Command",2);                // Wait for next command.
  78.  
  79.   cputs ("R SH^M");                      // Show conferences.
  80.   return (0);                            // continuous display
  81. }                                        // and quit to "main".
  82.  
  83. //-----------------------------------------------------------
  84. // Section 1 starts registration.
  85. //-----------------------------------------------------------
  86.  
  87. SECTION1()
  88. {
  89. int mo, ee, pw, sa, pc, hp, wp, ok;      // For tracking.      
  90.  
  91. // Start tracking messages.
  92.  
  93.   mo = track ("-more-- (Y/n):",0);      // More?
  94.   ee = track (" for english) ",1);      // Enter for English
  95.   pw = track ("logon password",0);      // Please enter your logon password
  96.  
  97.   tmark = timer_start (tol);             // wait up to 30 sec. for 
  98.                                          // each response.
  99.   while ((stat=trig()) > 0)              // answer any logon questions
  100.   { if (stat == pw)                      // Password?
  101.     { output (passw);                    // Send it. Now we can start
  102.                                          // tracking.....
  103.       sa = track ("street address",0);   // ......street address
  104.       pc = track ("ode and town :",0);   // ......postal code and town
  105.       hp = track ("home telephone",0);   // ......home telephone number
  106.       wp = track ("work telephone",0);   // ......work telephone number
  107.       ok = track (" your answers:",0);   // Satisfied with your answers
  108.     }
  109.     else if (stat == ee)                 // Language key  
  110.       cputs ("^M");                      // ENTER for English.
  111.  
  112.     else if (stat == mo)                 // More?
  113.       cputs ("N^M");                     // No.
  114.  
  115.     else if (stat == sa)                 // Street address
  116.       output (addr);
  117.  
  118.     else if (stat == pc)                 // Postal code.
  119.       output (mail);                     // give street address.
  120.  
  121.     else if (stat == hp)                 // Home telephone number
  122.       output (htel);                     // give home phone number.
  123.  
  124.     else if (stat == wp)                 // Work telephone number
  125.       output (wtel);                     // give work phone number.
  126.  
  127.     else if (stat == ok)                 // Satisfied with answers.
  128.     { cputs ("Y^M");                     // Yes I am (satisfied).
  129.       ok = 0;                            // OK return.
  130.       break;
  131.     }
  132.   }
  133.   release();
  134.   return (ok);                           // Fail.
  135. }
  136.  
  137. //-----------------------------------------------------------
  138. // Section 2 completes registration.
  139. //-----------------------------------------------------------
  140.  
  141. SECTION2()
  142. {
  143. int pc, pw, mo, ae, lk, ml, of, mn, yl, cm, ec;   // For tracking.
  144.  
  145. // Start tracking messages.
  146.  
  147.   pw = track ("s will echo)",0);         // Password entry.
  148.   ae = track ("Type an 'AE'",0);         // Request for Æ
  149.   ml = track (" line (Y/N)?",0);         // Middle of the line?
  150.   of = track ("creen (Y/N)?",0);         // Disappear?
  151.   yl = track ("our liking):",0);         // Not to your liking?
  152.   pc = track ("your choice ",0);         // Protocol choice.
  153.   mn = track (" MBBS (Y/N)?",0);         // Want manual?
  154.   cm = track ("(? for menu)",0);         // Command:
  155.   ec = track (" continue...",0);         // Enter to continue...
  156.   mo = 0;
  157.  
  158.   tmark = timer_start (tol);             // Wait up to 30 sec.
  159.  
  160.   while ((stat=trig()) > 0)              // answer any logon questions.
  161.   { if (stat == pw)  
  162.     { output (passw);                    // Send password.
  163.       if (!mo)                           // Start tracking this now.
  164.         mo = track ("--more--",0);
  165.     }   
  166.     else if (stat == mo                  // more?
  167.     ||       stat == ec                  // Enter to continue?
  168.     ||       stat == mn)                 // Manual?         
  169.       cputs ("N^M");                     // No thanks.
  170.  
  171.     else if (stat == ae)                 // Norwegian 'Æ'
  172.       cputs("Æ");                        // Type an 'Æ'.
  173.  
  174.     else if (stat==ml                    // Middle of the line?
  175.          ||  stat==of)                   // ...disappear off the screen?         
  176.       cputs("Y^M");                      // Answer Y to ANSI.
  177.  
  178.     else if (stat == yl)                 // Rules to your liking?
  179.       cputs("Y");                        // YES. MBBS doesn't expect
  180.                                          // a CR here.
  181.     else if (stat == pc)                 // Protocol choice?
  182.       output (hprot);                    // Send protocol.
  183.  
  184.     else if (stat == cm)                 // 1.st command.   
  185.       break;
  186.   }
  187.   release();                             // Release tracks.
  188.   return (0);                            // Return OK.
  189. }
  190.                                          
  191. //-----------------------------------------------------------
  192. // Wrong BBS type.
  193. //-----------------------------------------------------------
  194.  
  195. wrongBBS()
  196. {
  197. str help[48];
  198.  
  199.     failtone();                          // Alarm.    
  200.     help = "This script is for ";        // Catenate strings.
  201.     strcat (help,thisBBStype);
  202.     strcat (help," only!");
  203.     status_wind (help,20);               // Display message for 2 sec.
  204. }
  205.  
  206. //-----------------------------------------------------------
  207. // Play fail tone.
  208. //-----------------------------------------------------------
  209.  
  210. failtone()
  211. {
  212.   int n;
  213.   for (n=140; n > 10; n = 100*n/120) 
  214.   { tone(n*10,12);